<template>
  <div style="margin-top: 60px;margin-left:450px;width: 300px;height: 500px;border: 0px solid red;">
    <el-form :model="ruleForm" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="人才类型" prop="talenttype">
        <el-input v-model="ruleForm.talenttype"></el-input>
      </el-form-item>


      <el-form-item label="急需人才类型" prop="need">
        <el-input v-model="ruleForm.need"></el-input>
      </el-form-item>


      <el-form-item label="急需人才数量" prop="quantity">
        <el-input v-model="ruleForm.quantity" ></el-input>
      </el-form-item>

      <el-form-item label="创建时间" prop="creatdate">
        <el-input v-model="ruleForm.creatdate"></el-input>
      </el-form-item>

      <el-form-item label="请审批" prop="state">
        <el-radio-group v-model="ruleForm.state">
          <el-radio :label="2" :value="2">通过</el-radio>
          <el-radio :label="3" :value="3">未通过</el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">开始审批</el-button>
        <el-button @click="goback">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "ApprovalNeed",
  data() {
    return {
      ruleForm: {
        talenttype: '',
        need: '',
        quantity: '',
        state: '',
        creatdate: '',
      },
    };
  },
  methods:{
    goback(){
      this.$router.push("/approvalAdd")
    },
    submitForm(formName) {
      const _this = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(_this.ruleForm)
          axios.put('http://localhost:8081/talent/updateNeed/'+ _this.$route.query.id,_this.ruleForm).then(function (resp){
            _this.$alert(_this.ruleForm.talenttype + '   审批完成', '', {
              confirmButtonText: '确定',
              callback: action => {
                _this.$router.push('/approvalAdd')
              }
            })
          })
        }
      });
    }
  },
  created() {
    const _this = this
    axios.get('http://localhost:8081/talent/findNeed/'+ _this.$route.query.id).then(function (resp){
      _this.ruleForm = resp.data
    })
    axios.get('http://localhost:8081/talent/needs/'+ _this.$route.query.id).then(function (resp){
      _this.ruleForm.need = resp.data.talenttype
    })
  }
}
</script>

<style scoped>

</style>